import {ApiProperty} from '@nestjs/swagger';
import {ModelOptions, prop, Ref} from '@typegoose/typegoose';
import {Course} from "@libs/db/models/course.model";
import {User} from "@libs/db/models/user.model";
import {Episode} from "@libs/db/models/episode.model";

@ModelOptions({
  schemaOptions: {
    timestamps: true,
    versionKey: false
  }
})
export class Comment {
  @ApiProperty({description: '用户ID'})
  @prop({ref: () => User})
  user: Ref<User>

  @ApiProperty({description: '评论类型'})
  @prop({enum: ['Course', 'Episode']})
  type: string

  @ApiProperty({description: '评论数据ID'})
  @prop({refPath: 'type'})
  object: Ref<Course | Episode>

  @ApiProperty({description: '评论内容'})
  @prop()
  content: string
}
